Repository navigation
fix: resolve source map URLs relative to CLI output - #2192
Open
sergioperezcheco wants to merge 1 commit into
Open
sergioperezcheco wants to merge 1 commit into
sergioperezcheco wants to merge 1 commit into
Conversation
Assisted-by: Hermes AI Signed-off-by: sergioperezcheco <checo520@outlook.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused implementation and regression coverage support the intended behavior, with no unresolved blocking findings.
No open issues 🎉
What changed in this PR
Fixes CLI source-map links so generated JavaScript references the map’s actual filesystem location.
Changes:
- Resolves and encodes map URLs relative to the JavaScript output.
- Uses file URLs across Windows drives or UNC shares, including during minification.
- Adds regression coverage while preserving map destinations and stdout behavior.
| File | Description |
|---|---|
| spec/precompiler.js | Adds normal, minified, encoded-path, and Windows regression cases. |
| lib/precompiler.js | Computes source-map URLs and passes them through minification. |
Review effort: Balanced
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The CLI writes
--maprelative to the working directory but copies that filesystem path directly intosourceMappingURL. With-f dist/templates.js --map maps/templates.js.map, consumers look underdist/maps/instead of finding the generated map; spaces,#, and%in map names also produce incorrect URLs.Compute the URL relative to the generated JavaScript file, encode its path components, and use a file URL for different Windows drives or UNC shares. The map still goes to the original filesystem destination, stdout behavior is unchanged, and minification uses the same URL.
Added normal/minified regression cases, including Windows drive and UNC paths. Locally,
pnpm test,pnpm run lint, publish-project unit tests, and real CLI map-file readback passed on macOS/Node 22. Windows path tests also passed with apath.win32adapter; native Windows, Linux integration, and other Node versions remain for CI. Dependencies were reused locally rather than installed with a fresh frozen lockfile.This touches the same imports/comment lines as #2186 but fixes a separate path-resolution problem. A temporary composition preserving its sanitizer passed these ordinary CLI tests; its security tests were not run, and none of its changes are included here.
Implemented and reviewed with AI assistance (Hermes); this is not a claim of human review.